//检查是否登入成功
check(//登入成功
	function (result) {
		//保存登入ID
		if (sessionStorage.getItem("key") !== JSON.stringify(result.data.id)) {
			sessionStorage.setItem("key", JSON.stringify(result.data.id))
		}
		//显示登入名字
		$(".name").text(result.data.name)
		//获取投票列表
		GETlist();
		//注销请求
		logout("./index1.html");
		//不同ID第一次登入提醒
		first(result);
	})
function GETlist() {
	//获取投票列表
	AJAX("GET", Burl.vote_list, null,
		function (result) {
			for (var i = 0; i < result.data.length; i++) {
				var title = $("<div class='title'></div>")
				title.append($("<div class='list'>" + result.data[i].title + "<br>" + "<span>" + Gettime(result.data[i].createdAt) + "</span>" + "</div>").attr("id", result.data[i].id))
				title.append($("<div class='count'>" + result.data[i].count + "人已参与" + "</div>"))
				$("#main").append(title)
			}
			//点击跳转投票详情
			$(".list").on("click", function () {
				window.location.href = './options1.html?id=' + this.id
			})
		})
}
//不同ID第一次登录提醒
function first(result) {
	var currentday = new Date()
	var perTime = currentday.getFullYear() + "-" + currentday.getMonth() + "-" + currentday.getDate() + result.data.id
	if (localStorage.getItem("Date" + result.data.id) !== perTime) {
		localStorage.setItem("Date" + result.data.id, perTime)
		alert("欢迎登录")
	}
}